﻿using ET.Monitor.DAL;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class ChartModel
    {
        public ChartModel(string userId)
        {
            uid = userId;
        }
        public ChartModel(int count, string level)
        {
            grad = count;
            levelGrad = level;
        }
        public ChartModel(int count, int index, string userId)
        {
            pageIndex = index;
            pageSize = count;
            uid = userId;
        }

        public ChartModel(string modelId, string userid, string ymanu, int ymax, int ymin, int at, string describe)
        {
            mid = modelId;
            uid = userid;
            y = ymanu;
            max = ymax;
            min = ymin;
            auto = at;
            desc = describe;
        }
        public ChartModel(string paratId, string modelId, string pinlv, string pianyiliang, int ymax, int ymin, int at, string ut, string jm, string fm)
        {
            pid = paratId;
            mid = modelId;
            pl = pinlv;
            pyl = pianyiliang;
            max = ymax;
            min = ymin;
            auto = at;
            unit = ut;
            judgeModel = jm;
            formula = fm;
        }
        public ChartModel(string[] point, string[] name, DateTime dts, DateTime dte, int sd)
        {
            points = point;
            names = name;
            sTime = dts;
            eTime = dte;
            seconds = sd;
        }

        public ChartModel(string cid, string title, string formula, string oTitle)
        {
            chid = cid;
            chtitle = title;
            chformula = formula;
            chOTitle = oTitle;
        }

        string[] points = null, names = null;
        DateTime sTime = new DateTime();
        DateTime eTime = new DateTime();
        int seconds = 0;

        int grad = 0, pageSize = 0, pageIndex = 0, max = 0, min = 0, auto = 0;
        string uid = "", levelGrad = "", pid = "", mid = "", y = "", desc = "", pl = "", pyl = "", unit = "", judgeModel = "", formula = "", chid = "", chtitle = "", chformula = "", chOTitle = "";
        ChartDAL dal = new ChartDAL();
        DataTable hisChart;

        public DataTable HisChart
        {
            get { return dal.Get_Chartid(uid); }
            set { hisChart = value; }
        }
        DataTable level;

        public DataTable Level
        {
            get { return dal.GetLevel(grad, levelGrad); }
            set { level = value; }
        }

        //模板
        DataTable dtModel;

        public DataTable DtModel
        {
            get { return dal.GetModelPaging(pageSize, pageIndex, uid); }
            set { dtModel = value; }
        }

        //模板数量
        int countModel;

        public int CountModel
        {
            get { return dal.GetModelCount(uid); }
            set { countModel = value; }
        }

        //趋势测点信息
        DataTable dtPoint;

        public DataTable DtPoint
        {
            get { return dal.GetLinePointInfo(uid); }
            set { dtPoint = value; }
        }

        //模板那编码最大值
        int modelMax;

        public int ModelMax
        {
            get { return dal.GetModelMax(); }
            set { modelMax = value; }
        }

        //添加模板
        bool add;

        public bool Add
        {
            get { return dal.AddModel(mid, uid, y, max, min, auto, desc); }
            set { add = value; }
        }

        //添加模板属性
        bool addAttribute;

        public bool AddAttribute
        {
            get { return dal.AddModelPoint(pid, mid, pl, pyl, max, min, auto, unit, judgeModel, formula); }
            set { addAttribute = value; }
        }

        bool del;

        public bool Del
        {
            get { return dal.delModel(uid); }
            set { del = value; }
        }

        //string tagVal;

        //public string TagVal
        //{
        //    get { return dal.GetMongdbString(uid); }
        //    set { tagVal = value; }
        //}

        #region 自定义趋势
        IList<Hashtable> list;

        public IList<Hashtable> List
        {
            get { return dal.GetLine(points, names, sTime, eTime, seconds); }
            set { list = value; }
        }
        #endregion

        #region EditFormula
        bool editFormula;

        public bool EditFormula
        {
            get { return dal.EditFormula(chid, chtitle, chformula,chOTitle); }
            set { editFormula = value; }
        }
        #endregion
    }
}
